home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
me_cd25.zip
/
MUTT2.ZIP
/
MODELINE.MUT
< prev
next >
Wrap
Text File
|
1992-11-09
|
4KB
|
146 lines
;; modeline.mut : Modeline central. Control what the mode line looks
;; like and other mode related stuff.
;; Modeline format:
;; Change_flag Buffer-name (major-mode : minor-mode) File: File-name
;; Change_flag : -- or **
;; major_mode : "", C, Mutt, Picture, etc
;; minor_mode : comment, etc
;; Routines:
;; (local-modeline-hook
;; name-of-the-routine-to-call-instead-of-modeline-hook)
;; If the buffer has a local modeline-hook, it is called instead of the
;; global (modeline-hook).
;; (major-mode name-of-major-mode) : (major-mode "foo") sets the major
;; mode name to foo (displayed on the modeline) and (major-mode)
;; returns the current major mode name.
;; (minor-mode name-of-minor-mode)
;; (clear-modes) : Remove all the local key bindings, mode names and
;; reset the buffer local sysvars.
;; Uses:
;; Buffer variables:
;; major-mode
;; minor-mode
;; local-modeline-hook
;; Needed:
;; A way to stack modes so I can easily nest modes.
;; C Durland 10/89 Public Domain
(include me2.h)
(string message)
(defun
local-modeline-hook (string hook-name)
{ (buffer-var "local-modeline-hook" hook-name) }
major-mode (string name) { (mode-name "major-mode" (push-args 0)) }
minor-mode (string name) { (mode-name "minor-mode" (push-args 0)) }
clear-modes
{
(bind-local-key "clear-keymap")
(major-mode "")(minor-mode "")
(tab-stops 0)(word-wrap 0)
;;!! probably should have a buffer-var "clear-mode", that, if it exists, is
;; the name of a routine that will get rid of all the mode stuff.
}
modeline-message (string text)
{
(if (== (nargs) 1) ;; got a text
{
(message text)
;;;!!! need to update all visible buffers
(buffer-flags -1 BFMode) ;; force update of modeline
})
message ;; return the message
}
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;; Modeline Hook ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Global rouine to format a modeline for a buffer.
;; If the buffer has its own modeline hook, that is called instead.
;; Returns: A string to be used as the modeline.
(defun
modeline-hook
{
(if (!= "" (buffer-var "local-modeline-hook"))
{
(floc (buffer-var "local-modeline-hook")())
(done)
})
(concat
message
(if (!= 0 (bit-and BFNoCare (buffer-flags -1)))
" "
(if (buffer-modified -1) "**" "--"))
" ME2 "
(if (!= 0 (overstrike)) "[jam] " "")
"-- " (buffer-name -1) " "
(modes) ;; "(modes)" or "--"
(if (!= "" (file-name -1))
(concat " File:" (sub~ (file-name -1)) " ")
"")
"-" ;; repeat this to the end of the modeline
)
}
modes HIDDEN ;; spit out the major and minor mode names
{
(concat
(if (!= "" (buffer-var "major-mode"))
{
(concat
"("
(buffer-var "major-mode")
(if (!= "" (buffer-var "minor-mode"))
(concat " : " (buffer-var "minor-mode"))
"")
")" )
}
"--"))
}
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;; Gory details ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun
init-mline-bvars
{
(create-buffer-var STRING "local-modeline-hook" "major-mode" "minor-mode")
}
!1 MAIN HIDDEN ;; do this WAY early, before mode-line-hook is called
{
(init-mline-bvars) ;; make sure *scratch* is updated
(register-hook BUFFER-CREATED-HOOK "init-mline-bvars")
}
mode-name (string mode-var mode-name) HIDDEN
{
(if (== (nargs) 2) ;; got mode-name
{
(buffer-var mode-var mode-name)
(buffer-flags -1 BFMode) ;; force update of modeline
})
(buffer-var mode-var) ;; return the mode name
}
)
(defun
sub~ (string dir-name) HIDDEN ; convert /users/craig/... to ~/...
{
(int n)
(n (length-of (getenv "HOME")))
(if (and (!= n 0) (== (getenv "HOME") (extract-elements dir-name 0 n)))
(concat "~" (extract-elements dir-name n 1000))
dir-name
)
}
)